# coding=utf-8
import unittest
from .. import TanachParser

class TestTanachParser(unittest.TestCase):
  '''Unit tests for TanachParser.'''

  def test_combine(self): pass # Requires I/O; may need to refactor for testing.

  def test_scrub(self):
    '''Expected to clean up a bit of text.'''

    text = '''<P><B>א א,א</B> <BIG>אָ</BIG>דָם שֵׁת, אֱנוֹשׁ. 
<B>א א,ב</B> קֵינָן מַהֲלַלְאֵל, יָרֶד. 
<B>א א,ג</B> חֲנוֹךְ מְתוּשֶׁלַח, לָמֶךְ.'''

    test = TanachParser.scrub(text)
    check = ['\xA0', '{', '}', '<', '/', '>', '.', ',', ';', '-', '[', ']' ]
    for char in check:
      self.assertFalse(char in test)

  def test_tokenize(self):
    '''Expected to produce accurate map of words.'''
    text = u'אָדָם אֱנוֹשׁ אָדָם'
    expected = {
      u'אֱנוֹשׁ': {
        'hebrew': u'אֱנוֹשׁ',
        'english': ' aleph chataf-segol nun cholom-malei shin ',
        'has_shva': 'N',
        'syllable_count': 2,
        'frequency_count': 1,
        'hashem_name': False },
      u'אׇדׇם': {
        'hebrew': u'אָדָם', 
        'english': ' aleph kamatz dalet kamatz mem-sofit ',
        'has_shva': 'N',
        'syllable_count': 2,
        'frequency_count': 2,
        'hashem_name': False }    
    }
    
    test = TanachParser.tokenize(text) 
    self.assertEqual(test[u'אֱנוֹשׁ'], expected[u'אֱנוֹשׁ'])
    self.assertEqual(test[u'אָדָם'], expected[u'אׇדׇם'])
    
if __name__ == '__main__': unittest.main()